package com.glela.api.pay.yeepay;

/**
 * 易宝图片解析
 * @author MaoZeYao
 *
 */
public class YeePayImageDeal {
	
	public static void main(String[] args) throws Exception {
		dealYeePayImage("123");
	}
	
	/**
	 * 解析易宝返回的图片
	 * @param strImage
	 * @return
	 * @throws Exception
	 */
	public static String dealYeePayImage(String strImage) throws Exception {
		// 返回的图像参数HexImage
		String hexImageString = "89504E470D0A1A0A0000000D494844520000008B0000008B0802000000DE7BFDA80000039B4944415478DAEDDA5172A340100451EE7F69FB021B2BE8CA6A90493E6559C03C829EA99EE3C7E3D9C7E1107C87D0911DFFF8DD2BFF459DEB3F9F5C1B9413977AE93292515548218558A1D99DCC6E7B06139E34FC1DEA4FE7CFA590420A9584668345551DEA41A10ADBACE621A3AA90420A3D5CE8D2BDCD80A9210EEB227E830A29A4D0ABEAD0D13F2845851452E82B8466D3DCD935E1D3DCD977369701B7A53E0A29F47AA1DE1BFCCD9F3CA883E7270ABD5508DB987247831C0F557B75F1FEDD580A29F456216A151DE22DBCE5F167114F22145248A186D0E6D2BD17B3F6FA552155929E28A49042ACD0ACA28413D670E61A4A530F1CD5D302D6430A29A4D089B9DC6C721C0E442F02C0FB3A979E8664C41452482144889A0AE3896778F6CD76CE8CEAE363A190420A2142B3776838C40B0589DAA313022781B2420A29D4169A85026182D08B1BF0764EF808CEFB430A29A450D605C7BBC554AC19769E28B3A4E533A9430A29A41024349BF8F6A24FAA0E2DD43C6A10145248A186D042D7A4B739E69630B40DA390420A9584F04CA1975D861907D53BEF292AA49042A0D0BD5749850254FC1166016C3D534821854A42B76C7C095B2CD4BC396C3885C3A290420A5585C2F77EAF7B1D5ECF2DD5B49B6D2BA49042D05E1FBC7913766816F60C51BB7666B54A2185146A0851FB6F16F2D6B00EF51AED541D02D6430A29A4D03332855B1ADBE114BF97F69275482185143A912984A505CF2EC30A47CD92F192394F4E15524821A83F14BEA6C38244E5A49BED2E36C85048218510A130FAC49B40BDF6732F1AC6170F0A29A45055287CA787B561A10F1D6EFA5968E12BA490425521AA12845B61F0553D5E997A454B2185140285C2FBC763446A93CD6665A226E2679353851452E88A505851A87E4C38D661C681870B483B5C2185144284907EED7802DD0B17A8D9FFEC9A9160452185144284280F6ADA4DD5187C3B111E7F7C3CA9420A295412C257F578EF9CBA426A224E75D4145248A1AA10359B0CEF246CF0F49E18FC972FD7218514526824B4D0FC5E588487B16FB835877A98145248A18610758437B9B0F2A714F18CE37272AA90420A5D11C2DFA1D41A9E6ABDE38AB3D802982928A49042F46C1BCF52A9A64BF883D410E34F83420A29B423D45B9FDF3293C6E7FAED2841218514FA0342546D08FFB430594F4EAA90420A7D8B50B8B307EFC153F3E6F64E23851452A824349B7AE254618307BFAF85BC55218514AA0A513B69A80C94FA777CD30FB50CF8F81D8514520811F278ECA1D0D38F5F11FE4D12AC4030FE0000000049454E44AE426082 DB5172E3300C0451DFFFD2C90D1212D343CA76EB335B892D3E950062B8AF1FAF675F2F97E03D845ED9F5D7072 CFC56F8597FFCC1E1A22C7CD5ADAF91ACAA420A29C40ACDEE84FAAD2DCEDE5ACFBE73697D145248A192D06CB1 F08AD223A7169DAA4C0A29A4D09B0ACD6AC356434F2DF1ECF1A29E60851452E84D85C2DE9ADA9FCF163DACAF0 A29A4D0938566AF7BAA19A5C6A3E16CB7570EAF4D7D1452E8EB857A6FF06FFEC983123C7FA2D0B70A610753B2 D07A769357B2283C7AFFE7AC8F420A299409E1494F1848F7DEF2F8B3D84BCB145248215028DC0FCF4A0235270 D2B1C3EB608976EB5DB5648218520A1B003A6E2F0D9E833CCA27A33D9F53FA890420AB142784B4D0D1766A585 EAA4F1C76B3E39554821854642D4AE1E5FFDD9425C8973A889F0F6D4472185145A10C253136A8240F5D6BDA96 858C2155248A1EB4207F6D5618DC14329AAD884555921851402854EA641F82C005F6B7CDE3AABDC0A29A45043 08DF69F79ADADE899CF0D1A1F6150A29A41028742035C10B1B5E90A8790A02A390420AB14278204DDDD2439E8 FB0D4256DB7420A29C40A9D5C507C28105E781286D4338514520811DA6A10F1E5A32216AA6F0E03A7305E5248 2185AA42D430747603781DC2C7ACF87E0038A7A090420A8DD2073CBC098BCD2CCEE9CD40A9EFB39A822BA4904 29050AF0EE143D5A705ED611DBADF6D2BA4D0470BCD12DC030DF495B34707BED8FA43A990420A5D143A19E784 A93CD5251F2899641D52482185B2FF9DB265964C0FC731762FEE0AFF89AC430A29A4D082D0AC893C705CA6178 7F746C3D47756482185AA42D43B9DDAC3E3397478E8A7775FDBF990420A293412A2660AD451186A578F5726BC 6829A490420D21BC89C4479FB366FD64650A3D80D9B6420A2994CD14A836B7F4BEDE5D35FC8450290E5748218 510A1709470A0F19D2D28D5FD5FD90F28A49042A0D0CC039F3BE035264CF70F94D57F3F542185142A09853D28 9B91806173AF110F6BF0EA6C5B218514CA847A1D305EBD66490FD51C537F79BB0E29A4904223A1596613DEED8 1B9E4C9DA493D4C0A29A4504388BAF0C122BEF3A7140FCC381452482150087F87E2DBFB93F17C383566E32585 145288153A3046A4429730C5A196B8FD3428A4904225A1DEFEFC4A271D8652D4486230A0514821853E40887AD D9F1CE0F6C6280A29A4D05B0885B7DD1B37CCEE8BFAD0C12228A4904225A1DE819EF0DC4CD2B956EF8B9AB72A A4904255A1D2C678DCD48665A377E827DC065C4BF01452E85B85BC1E7B29F4F4EB1762045A137848CC7F00000 00049454E44AE426082";
		System.out.println(hexImageString.length());
		// 转成image
		// byte[] b = hex2byte(hexImageString);
		// ByteArrayInputStream in = new ByteArrayInputStream(b);
		/*String imgurl = QiniuUtils.uploadByBytys64("file/yeePay/", b, "jpg");*/
		
		return null;
		/*BufferedImage image = ImageIO.read(in);
		// 输出
		ImageIO.write(image, "jpg", new File("C:/Users/MaoZeYao/Desktop/orderSn.png"));
		return null;*/
	}

	public byte[] hex2byte(String s) {
		byte[] src = s.toLowerCase().getBytes();
		byte[] ret = new byte[src.length / 2];
		for (int i = 0; i < src.length; i += 2) {
			byte hi = src[i];
			byte low = src[i + 1];
			hi = (byte) ((hi >= 'a' && hi <= 'f') ? 0x0a + (hi - 'a') : hi - '0');
			low = (byte) ((low >= 'a' && low <= 'f') ? 0x0a + (low - 'a') : low - '0');
			ret[i / 2] = (byte) (hi << 4 | low);
		}
		return ret;
	}

}
